/**
 * \class initializeDirectionsMap
 * \brief this class initialises the map content
 * \author mahlatse maraba
 */


var directionsMap;
var currentEventGMarkers = [];
var directions;


function initializeDirectionsMap()
{

    directionsMap = new GMap2(document.getElementById("directions_map_canvas"));
    directions = new GDirections(directionsMap);
    directionsMap.addControl(new GLargeMapControl());
    directionsMap.addControl(new GMapTypeControl());
    directionsMap.addControl(new GScaleControl());
    if (coordinateFinder.userLat != null && coordinateFinder.userLong !=null)
    {
        directionsMap.setCenter(new GLatLng(coordinateFinder.userLat,coordinateFinder.userLong), 12);
        userCoordinatePnt = new GLatLng(coordinateFinder.userLat,coordinateFinder.userLong);
        marker = new GMarker(userCoordinatePnt);
        currentEventGMarkers[0] = marker;
        directionsMap.addOverlay(new GMarker(userCoordinatePnt, userMarkerOptions));
    }
    else

    {
        directionsMap.setCenter(new GLatLng(-26,28), 12);
    }

    $("#directionsToEventContainer").hide();

}

function getDirections()
{
    directions.load("from:" + currentEventGMarkers[0].getPoint().lat()+ ", " + 	//using the directions object you now plot the direction
        currentEventGMarkers[0].getPoint().lng() +
        " to:" + currentEventGMarkers[1].getPoint().lat() + "," +
        currentEventGMarkers[1].getPoint().lng(),
        {
            getPolyline: true,
            getSteps: true
        });

    var htmlClear = "directions are suppossed to go here";
    document.getElementById("path_directions_guide").innerHTML = htmlClear;

    GEvent.addListener(directions,"load", function() {
        customPanel(directionsMap,"directionsMap",directions,document.getElementById("path_directions_guide"));
    });
}

